﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WCFMINERP.Contracts.DataContracts;

namespace WCFMINERP.DisjoinProForOutShop
{
    public partial class ULattice : UserControl
    {

        

        /// <summary>
        /// 格子序号
        /// </summary>
        public int _SerialNumber { get; set; }

        private int OrderNumber = 0;
        /// <summary>
        /// 订单所有产品数量
        /// </summary>
        public int _OrderNumber
        {
            get { return OrderNumber; }
            set { OrderNumber = value; }
        }

        private int ExistenceNumber = 0;
        /// <summary>
        /// 当前格子已经存在多少个
        /// </summary>
        public int _ExistenceNumber
        {
            get { return ExistenceNumber; }
            set { ExistenceNumber = value; }
        }

        /// <summary>
        /// 格子信息储存
        /// </summary>
        public Lattice Lattice { get; set; }


        public ULattice()
        {
            InitializeComponent();
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {
            Refreshdata();

            //foreach (Control n in this.Controls)
            //{
            //    if (n is Label)
            //    {
            //        n.Click += ULattice_Click;
            //        n.DoubleClick += ULattice_DoubleClick;
            //    }
            //}
        }

        public int _wd = 152;

        /// <summary>
        /// 给控件重新给值
        /// </summary>
        public void Refreshdata()
        {
            lbl_Name.MaximumSize = new System.Drawing.Size(_wd - 5, 0);
            lbl_OrderCode.MaximumSize = new System.Drawing.Size(_wd - 5, 0);

            lbl_SerialNumber.Text = _SerialNumber.ToString();
            lbl_Count.Text = _ExistenceNumber.ToString();
            lbl_sign.Text = "/" + _OrderNumber;
            lbl_Name.Text = "商户:";
            lbl_OrderCode.Text = "客户:";
            if (Lattice != null)
            {                
                //lbl_OrderName.Text = "名称:"+Lattice.OrderName;
                if (Lattice.OrderbagModel != null)
                {
                    lbl_Name.Text ="商户:"+ Lattice.OrderbagModel.ShopName;
                    lbl_OrderCode.Text = "客户:" + Lattice.OrderbagModel.ctmNames;
                }
            }
        }


        #region  事件

        //public delegate void PostClicks(ULattice shopUGrid);

        //public event PostClicks ShopDoubleClick;
        //public event PostClicks ShopClick;

        private void ULattice_Click(object sender, EventArgs e)
        {
            //ShopClick(this);
            GridHandle.OnClick(this);
        }

        private void ULattice_DoubleClick(object sender, EventArgs e)
        {
            //ShopDoubleClick(this);
            GridHandle.OnDoubleClick(this);
        }

        #endregion
    }
}
